package Csv2RDF;

import Json2RDF.Json2Java.OntologyClasses.Face;
import Json2RDF.Surface2RDF.IndexTable.Face2ResourceIndexTable;
import RDFManager.RDFReader;
import org.apache.jena.rdf.model.Resource;

/**
 * {@code Relation2RDF}的作用为将{@code Face}类维护的属性关系表写入RDF文件中
 */
public class Relation2RDF {

  /**
   * 读取{@code Face}类实体维护的属性关系表{@code Map<Face, List<Property>>}并写入RDF文件
   *
   * @param face 输入表面
   */
  public static void writeRelation(Face face) {
    Resource face1 = Face2ResourceIndexTable.faceResourceIdxTbl.get(face);
    face.getRelations().forEach((k, v) -> {
      Resource face2 = Face2ResourceIndexTable.faceResourceIdxTbl.get(k);
      v.forEach(property -> {
        RDFReader.model.add(face1, property, face2);
      });
    });
  }
}
